<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<% List<Supplier> suppliers=(List<Supplier>) session.getAttribute("suppliers");  
  List<Machine> machines= ( List<Machine> )session.getAttribute("machines"); %>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ include file="validOwner.jsp" %>
<link href="<%=basePath%>/styles/createDistribute.css" rel="stylesheet" type="text/css" />
<title>新增自提柜分配</title>
</head>
<body>
<script src="http://127.0.0.1:8080/houdoudou/js/checkboxFunction.js"  charset="UTF-8" type="text/javascript" >  </script>  
<script type="text/javascript">
/* 执行操作 */   
function do_action(){   
var supplierSelected=checkAll("form_saveDistribute","supplier");
var machineSelected=checkAll("form_saveDistribute","machine");
var timeSelected=checkAll("form_saveDistribute","time");
if (supplierSelected&machineSelected&timeSelected){   
  document.getElementById("form_saveDistribute").submit(); 
  return;
} 
 if(!supplierSelected){   
alert("商家未选择！");   
}   
if(!machineSelected){   
alert("自提柜未选择！");   
}
if(!timeSelected){   
alert("时间未选择！");   
}
} 
</script>

 
<h1 align="center">自提柜分配管理</h1>    
    <h2>新增自提柜分配</h2> 
    
    <div id="pagebody"><!--页面主体-->
     <form  id="form_saveDistribute" action="<%=basePath%>/owner4Jsp" >
    <div id="supplierPart">
                   商家<br/><br/>
    <% for(int i=0;i<suppliers.size();i++){ %>
    <input type="checkbox"  name= "supplier"  value="<%= suppliers.get(i).getTelnum() %>"/> 
    <%= suppliers.get(i).getName() %> <br/>
     <%} %>
    <input type="button" value="全选、全不选" onClick="selectAll('form_saveDistribute','supplier')" >
    
    </div>
    
     <div id="machinePart">
     自提柜<br/><br/>
      <% for(int i=0;i<machines.size();i++){ %>
    <input type="checkbox" name= "machine" value="<%= machines.get(i).getId() %>" />
    
     <%= machines.get(i).getName() %> <br/>
     <%} %>
      <input type="button" value="全选、全不选" onClick="selectAll('form_saveDistribute','machine')" >
    </div>
     
     <div id="timePart">
                  班次             <br/> <br/>
     <input type="checkbox" name="time" value="1" /> 早班 <br/>
     <input type="checkbox" name="time" value="2" /> 中班 <br/>
     <input type="checkbox" name="time" value="3" /> 晚班 <br/>    
      <input type="button" value="全选、全不选" onClick="selectAll('form_saveDistribute','time')" >
    </div>   
     <div class="clear"></div> 
  <br/>     <br/>
    
    <input type="hidden" name="affair" value="saveDistribute" />
  <P align="right">  <input type="button" value="创建" onClick="do_action()" ></P> <br/>
    </form> 
    </div>
    <br/> <br/>  <br/> <br/>
</body>
</html>
<script> 
//取出传回来的参数error并与yes比较
  var errorInfoA ='<%=request.getParameter("errorInfo")%>';
  var  errorInfo=decodeURI(errorInfoA);
  if(errorInfo!='null'){
   alert(errorInfo);}

</script>
<script type="text/javascript">
 function checkInput(){
 try
  { 
 document.getElementById("form_saveDistribute").submit();
}
catch(err)
  {
  txt="There was an error on this page.\n\n";
  txt+="Error description: " + err.message + "\n\n";
  txt+="Click OK to continue.\n\n";
  alert(txt);
  }

 
}
 </script>